/*
package service;


import dao.FruitDao;
import domain.Fruit;
import thread.SocketRunable;

import javax.print.attribute.standard.Severity;
import java.net.Socket;
import java.util.ArrayList;
import java.util.TreeSet;

public class FruitService extends SocketRunable {
    FruitDao dao = new FruitDao();
    ArrayList<Fruit> list = dao.findAllFruits();
    TreeSet<Fruit> sort = dao.sortByInventory();
    TreeSet<Fruit> fruitTreeSet = dao.sortByPrice();

    public FruitService(Socket socket) {
        super(socket);
    }

    public int getIndex(String num) {
        return dao.getIndex(num);
    }

    public void inventory(String fnum, int num, int[] arr) {
        dao.inventory(fnum, num, arr);
    }

    public void checkByPrice() {
        System.out.println("编号" + "\t\t\t" + "名称" + "\t\t" + "价格" + "\t\t" + "库存" + "\t\t" + "单位");
        fruitTreeSet.addAll(list);
        for (Fruit f : fruitTreeSet) {
            System.out.println(f.getNum() + "\t\t" + f.getName() + "\t\t" + f.getPrice() + "\t\t\t" + f.getInventory() + "\t\t\t" + f.getUnit());
        }
    }

    //顾客查看水果信息时的默认方法,按库存排序
    public void check() {
        System.out.println("编号" + "\t\t\t" + "名称" + "\t\t" + "价格" + "\t\t" + "库存" + "\t\t" + "单位");
        for (Fruit f : sort) {
            System.out.println(f.getNum() + "\t\t" + f.getName() + "\t\t" + f.getPrice() + "\t\t\t" + f.getInventory() + "\t\t\t" + f.getUnit());
        }
    }

    //管理员查看水果信息时的方法,直接读取文件中的水果信息,不支持排序
    public void managerCheck() {
        System.out.println("编号" + "\t\t\t" + "名称" + "\t\t" + "价格" + "\t\t" + "库存" + "\t\t" + "单位");
        for (Fruit f : list) {
            System.out.println(f.getNum() + "\t\t" + f.getName() + "\t\t" + f.getPrice() + "\t\t\t" + f.getInventory() + "\t\t\t" + f.getUnit());
        }
    }

    public ArrayList<Fruit> findAllFruits() {
        return list;
    }

    public boolean isExist(String num) {
        boolean flag = false;
        for (Fruit fruit : list) {
            if (fruit.getNum().equals(num)) {
                flag = true;
            }
        }
        return flag;
    }

    public void add(String num, String name, int price, int inventory, String unit) {
        dao.add(num, name, price, inventory, unit);
    }

    public void delete(String num) {
        dao.delete(num);
    }

    public void update(String num, Fruit newFruit) {
        dao.update(num, newFruit);
    }

    public int count(String name, int num) {
        int sum = 0;
        for (Fruit fruit : list) {
            if (name.equals(fruit.getName())) {
                sum += fruit.getPrice() * num;
            }
        }
        return sum;
    }
}
*/
